﻿<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Notes.aspx.cs" Inherits="Notes" Title="Журнал" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" Runat="Server">
    <div id="stats-left">
        <asp:RadioButtonList ID="rbtnTableType" runat="server" AutoPostBack="True" 
            Font-Bold="True" onselectedindexchanged="rbtnTableType_SelectedIndexChanged" Width="200px">
            <asp:ListItem Selected="True"> проведенные работы</asp:ListItem>
            <asp:ListItem> отказы оборудования</asp:ListItem>
        </asp:RadioButtonList><asp:DropDownList ID="ddlTypeQuery" runat="server" AutoPostBack="True"
            OnSelectedIndexChanged="ddlTypeQuery_SelectedIndexChanged" Width="160px">
            <asp:ListItem>за указанную дату</asp:ListItem>
            <asp:ListItem>за период с</asp:ListItem>
        </asp:DropDownList><asp:Calendar ID="cldrDateStart" runat="server" BackColor="White"
            BorderColor="#3366CC" BorderWidth="1px" CellPadding="1" DayNameFormat="Shortest"
            Font-Names="Verdana" Font-Size="8pt" ForeColor="#003399" Height="200px" OnSelectionChanged="cldrDateStart_SelectionChanged"
            SelectedDate="1998-05-01" ToolTip="начальная дата" VisibleDate="1998-05-01" Width="220px">
            <SelectedDayStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />
            <SelectorStyle BackColor="#99CCCC" ForeColor="#336666" />
            <WeekendDayStyle BackColor="#CCCCFF" />
            <TodayDayStyle BackColor="#99CCCC" ForeColor="White" />
            <OtherMonthDayStyle ForeColor="#999999" />
            <NextPrevStyle Font-Size="8pt" ForeColor="#CCCCFF" />
            <DayHeaderStyle BackColor="#99CCCC" ForeColor="#336666" Height="1px" />
            <TitleStyle BackColor="#003399" BorderColor="#3366CC" BorderWidth="1px" Font-Bold="True"
                Font-Size="10pt" ForeColor="#CCCCFF" Height="25px" />
        </asp:Calendar>
        <asp:Label ID="Label1" runat="server" Text="по" Visible="False"></asp:Label><asp:Calendar
            ID="cldrDateStop" runat="server" BackColor="White" BorderColor="#3366CC" BorderWidth="1px"
            CellPadding="1" DayNameFormat="Shortest" Font-Names="Verdana" Font-Size="8pt"
            ForeColor="#003399" Height="200px" OnSelectionChanged="cldrDateStart_SelectionChanged"
            SelectedDate="1998-05-05" ToolTip="конечная дата" Visible="False" VisibleDate="1998-05-05"
            Width="220px">
            <SelectedDayStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />
            <SelectorStyle BackColor="#99CCCC" ForeColor="#336666" />
            <WeekendDayStyle BackColor="#CCCCFF" />
            <TodayDayStyle BackColor="#99CCCC" ForeColor="White" />
            <OtherMonthDayStyle ForeColor="#999999" />
            <NextPrevStyle Font-Size="8pt" ForeColor="#CCCCFF" />
            <DayHeaderStyle BackColor="#99CCCC" ForeColor="#336666" Height="1px" />
            <TitleStyle BackColor="#003399" BorderColor="#3366CC" BorderWidth="1px" Font-Bold="True"
                Font-Size="10pt" ForeColor="#CCCCFF" Height="25px" />
        </asp:Calendar>
        <asp:Button ID="btnMakeReport" runat="server" 
            Text="Составить отчет" Width="160px" />
    </div>
    <div id="stats-right">
        <asp:Label ID="lbHeader" runat="server" Text="Данные" Font-Bold="True" ForeColor="White"></asp:Label>
        <asp:GridView ID="gvNotesJobs" runat="server"
            AutoGenerateColumns="False" CellPadding="4" ForeColor="#333333" Caption="Проведенные работы:" Font-Bold="False" 
            Font-Italic="False" Font-Strikeout="False" DataSourceID="dsNotesJobs" CaptionAlign="Left" Width="690px" DataKeyNames="id">
            <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
            <Columns>
                <asp:BoundField DataField="id" HeaderText="id" >
                    <ItemStyle Width="25px" />
                </asp:BoundField>
                <asp:BoundField HeaderText="Дата" DataField="DateStart" DataFormatString="{0:d}" ApplyFormatInEditMode="True" HtmlEncode="False" >
                    <ItemStyle Width="60px" />
                </asp:BoundField>
                <asp:BoundField HeaderText="Группа" DataField="GroupOf" >
                    <ItemStyle Width="50px" />
                </asp:BoundField>
                <asp:BoundField HeaderText="Оборудование" DataField="ItName" >
                    <ItemStyle Width="150px" />
                </asp:BoundField>
                <asp:BoundField HeaderText="Информация" DataField="Information" >
                    
                </asp:BoundField>
                <asp:CommandField ButtonType="Image" SelectImageUrl="~/images/edit.png" SelectText="--&gt;"
                    ShowSelectButton="True">
                    <ItemStyle BackColor="#E0E0E0" Width="20px" />
                </asp:CommandField>
            </Columns>
            <RowStyle BackColor="#EFF3FB" />
            <EditRowStyle BackColor="#E0E0E0" Font-Italic="False" Width="50px" />
            <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" BorderStyle="Solid" BorderWidth="1px" />
            <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
            <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
            <AlternatingRowStyle BackColor="White" />
        </asp:GridView>
            <asp:DetailsView ID="dvNotesJob" runat="server" AutoGenerateRows="False" CellPadding="4"
                CellSpacing="1" DataSourceID="dsNotesJobsDetails" ForeColor="#333333" GridLines="None"
                Height="50px" Width="690px">
                <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                <CommandRowStyle BackColor="#D1DDF1" Font-Bold="True" />
                <EditRowStyle BackColor="#2461BF" />
                <RowStyle BackColor="#EFF3FB" />
                <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
                <Fields>
                    <asp:BoundField DataField="id" HeaderText="id" InsertVisible="False" ReadOnly="True"
                        SortExpression="id" Visible="False" />
                    <asp:BoundField DataField="DateStart" HeaderText="Дата" SortExpression="DateStart" ApplyFormatInEditMode="True" DataFormatString="{0:d}" HtmlEncode="False" />
                    <asp:BoundField DataField="GroupOf" HeaderText="Группа" SortExpression="GroupOf" />
                    <asp:BoundField DataField="ItName" HeaderText="Оборудование" SortExpression="ItName" />
                    <asp:TemplateField HeaderText="Информация" SortExpression="Information">
                        <EditItemTemplate>
                            <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Information") %>' Width="550px"></asp:TextBox>
                        </EditItemTemplate>
                        <InsertItemTemplate>
                            <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Information") %>' Width="550px"></asp:TextBox>
                        </InsertItemTemplate>
                        <ItemStyle Width="550px" />
                        <ItemTemplate>
                            <asp:Label ID="Label1" runat="server" Text='<%# Bind("Information") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
            <asp:TemplateField ShowHeader="False">
                <EditItemTemplate>
                    <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" CommandName="Update"
                        Text="Сохранить"></asp:LinkButton>
                    <asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Cancel"
                        Text="Отмена"></asp:LinkButton>
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" CommandName="Insert"
                        Text="Добавить"></asp:LinkButton>
                    <asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Cancel"
                        Text="Отмена"></asp:LinkButton>
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Edit"
                        Text="Редактировать" ForeColor="black"></asp:LinkButton>
                    <asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="New"
                        Text="Добавить" ForeColor="black"></asp:LinkButton>
                    <asp:LinkButton ID="LinkButton3" runat="server" CausesValidation="False" CommandName="Delete"
                       OnClientClick = "return confirm('Действительно удалить?');" Text="Удалить"  ForeColor="black"></asp:LinkButton>
                </ItemTemplate>
            </asp:TemplateField>
                </Fields>
                <FieldHeaderStyle BackColor="#DEE8F5" Font-Bold="True" />
                <HeaderStyle BackColor="#507CD1" Font-Bold="False" ForeColor="White" />
                <AlternatingRowStyle BackColor="White" />
            </asp:DetailsView>
        <asp:GridView ID="gvNotesRefuse" runat="server"
            AutoGenerateColumns="False" CellPadding="4" ForeColor="#333333" 
            GridLines="Vertical" Caption="Отказы оборудования:" Font-Bold="False" 
            Font-Italic="False" Font-Strikeout="False" 
            DataSourceID="dsNotesRefuse" CaptionAlign="Left" Width="690px" DataKeyNames="id">
            <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
            <Columns>
                <asp:BoundField DataField="id" HeaderText="id" InsertVisible="False" SortExpression="id" >
                    <ItemStyle Width="25px" />
                </asp:BoundField>
                <asp:BoundField HeaderText="Что отказало" DataField="ItName" />
                <asp:BoundField HeaderText="Город (кол-во АП)" DataField="CityAP" Visible="False" >
                    <ItemStyle Width="130px" />
                </asp:BoundField>
                <asp:BoundField HeaderText="Время отказа" DataField="DateStart" ApplyFormatInEditMode="True" DataFormatString="{0:dd.MM.yy hh:mm}" HtmlEncode="False" >
                    <ItemStyle Width="100px" />
                </asp:BoundField>
                <asp:BoundField HeaderText="Время восстановления" DataField="DateStop" ApplyFormatInEditMode="True" DataFormatString="{0:dd.MM.yy hh:mm}" HtmlEncode="False" Visible="False" >
                    <ItemStyle Width="100px" />
                </asp:BoundField>
                <asp:BoundField HeaderText="Простой" DataField="Duration" >
                    <ItemStyle Width="30px" />
                </asp:BoundField>
                <asp:BoundField HeaderText="Причина, принятые меры" DataField="Reasons" />
                <asp:CommandField ButtonType="Image" SelectImageUrl="~/images/edit.png" SelectText="--&gt;"
                    ShowSelectButton="True">
                    <ItemStyle BackColor="#E0E0E0" Width="20px" />
                </asp:CommandField>
            </Columns>
            <RowStyle BackColor="#EFF3FB" />
            <EditRowStyle BackColor="#2461BF" />
            <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
            <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
            <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
            <AlternatingRowStyle BackColor="White" />
        </asp:GridView>
        <asp:DetailsView ID="dvNotesRefuse" runat="server" AutoGenerateRows="False" CellPadding="4"
                CellSpacing="1" DataSourceID="dsNotesRefuseDetails" ForeColor="#333333" GridLines="None"
                Height="50px" Width="690px">
            <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
            <CommandRowStyle BackColor="#D1DDF1" Font-Bold="True" />
            <EditRowStyle BackColor="#2461BF" />
            <RowStyle BackColor="#EFF3FB" />
            <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
            <FieldHeaderStyle BackColor="#DEE8F5" Font-Bold="True" />
            <HeaderStyle BackColor="#507CD1" Font-Bold="False" ForeColor="White" />
            <AlternatingRowStyle BackColor="White" />
            <Fields>
                <asp:BoundField DataField="id" HeaderText="id" InsertVisible="False" ReadOnly="True"
                    SortExpression="id" />
                <asp:BoundField DataField="ItName" HeaderText="ItName" SortExpression="ItName" >
                    <ItemStyle Width="457px" />
                </asp:BoundField>
                <asp:BoundField DataField="CityAP" HeaderText="CityAP" SortExpression="CityAP" />
                <asp:BoundField DataField="DateStart" HeaderText="DateStart" SortExpression="DateStart" />
                <asp:BoundField DataField="DateStop" HeaderText="DateStop" SortExpression="DateStop" />
                <asp:BoundField DataField="Duration" HeaderText="Duration" SortExpression="Duration" />
                <asp:TemplateField HeaderText="Reasons" SortExpression="Reasons">
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Reasons") %>' Width="450px"></asp:TextBox>
                    </EditItemTemplate>
                    <InsertItemTemplate>
                        <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Reasons") %>' Width="450px"></asp:TextBox>
                    </InsertItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="Label1" runat="server" Text='<%# Bind("Reasons") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField ShowHeader="False">
                <EditItemTemplate>
                    <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" CommandName="Update"
                        Text="Сохранить"></asp:LinkButton>
                    <asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Cancel"
                        Text="Отмена"></asp:LinkButton>
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" CommandName="Insert"
                        Text="Добавить"></asp:LinkButton>
                    <asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Cancel"
                        Text="Отмена"></asp:LinkButton>
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Edit"
                        Text="Редактировать" ForeColor="black"></asp:LinkButton>
                    <asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="New"
                        Text="Добавить" ForeColor="black"></asp:LinkButton>
                    <asp:LinkButton ID="LinkButton3" runat="server" CausesValidation="False" CommandName="Delete"
                       OnClientClick = "return confirm('Действительно удалить?');" Text="Удалить"  ForeColor="black"></asp:LinkButton>
                </ItemTemplate>
            </asp:TemplateField>                
            </Fields>
        </asp:DetailsView>
        <asp:Label ID="lbItog" runat="server" Text="Итого работ:"></asp:Label>
        
        <asp:SqlDataSource ID="dsNotesJobs" runat="server" ConnectionString="<%$ ConnectionStrings:AtlasDB %>" SelectCommand="SELECT * FROM [NotesJobs] WHERE ([DateStart] = @DateStart) ORDER BY [DateStart]">
            <SelectParameters>
                <asp:ControlParameter ControlID="cldrDateStart" Name="DateStart" PropertyName="SelectedDate"
                    Type="DateTime" />
            </SelectParameters>
        </asp:SqlDataSource>
        <asp:SqlDataSource ID="dsNotesJobsDetails" runat="server" ConnectionString="<%$ ConnectionStrings:AtlasDB %>" SelectCommand="SELECT * FROM [NotesJobs] WHERE ([id] = @id)" InsertCommand="INSERT INTO NotesJobs(DateStart, GroupOf, ItName, Information) &#13;&#10;VALUES (@DateStart, @GroupOf, @ItName, @Information) " OnInserted="dsNotesJobsDetails_Inserted" OnUpdated="dsNotesJobsDetails_Updated" UpdateCommand="UPDATE NotesJobs &#13;&#10;SET DateStart = @DateStart, GroupOf = @GroupOf, ItName = @ItName, Information = @Information&#13;&#10;where id = @id">
            <SelectParameters>
                <asp:ControlParameter ControlID="gvNotesJobs" Name="id" PropertyName="SelectedValue"
                    Type="Int32" />
            </SelectParameters>
            <UpdateParameters>
                <asp:Parameter Name="DateStart" />
                <asp:Parameter Name="GroupOf" />
                <asp:Parameter Name="ItName" />
                <asp:Parameter Name="Information" />
                <asp:ControlParameter ControlID="gvNotesJobs" Name="id" PropertyName="SelectedValue" />
            </UpdateParameters>
            <InsertParameters>
                <asp:Parameter Name="DateStart" />
                <asp:Parameter Name="GroupOf" />
                <asp:Parameter Name="ItName" />
                <asp:Parameter Name="Information" />
            </InsertParameters>
        </asp:SqlDataSource>
        <asp:SqlDataSource ID="dsNotesRefuse" runat="server" ConnectionString="<%$ ConnectionStrings:AtlasDB %>" InsertCommand="INSERT INTO NotesRefuse(ItName, CityAP, DateStart, DateStop, Duration, Reasons) &#13;&#10;VALUES (@ItName, @CityAP, @DateStart, @DateStop, @Duration, @Reasons) " SelectCommand="SELECT * FROM [NotesRefuse]" UpdateCommand="UPDATE NotesRefuse &#13;&#10;SET ItName = @ItName, CityAP = @CityAP, DateStart = @DateStart, DateStop = @DateStop, Duration = @Duration, Reasons = @Reasons&#13;&#10;where id = @id" ProviderName="System.Data.SqlClient">
        </asp:SqlDataSource>
        <asp:SqlDataSource ID="dsNotesRefuseDetails" runat="server" ConnectionString="<%$ ConnectionStrings:AtlasDB %>" SelectCommand="SELECT * FROM [NotesRefuse] WHERE ([id] = @id)" InsertCommand="INSERT INTO NotesRefuse(ItName, CityAP, DateStart, DateStop, Duration, Reasons) &#13;&#10;VALUES (@ItName, @CityAP, @DateStart, @DateStop, @Duration, @Reasons) " UpdateCommand="UPDATE NotesRefuse &#13;&#10;SET ItName = @ItName, CityAP = @CityAP, DateStart = @DateStart, DateStop = @DateStop, Duration = @Duration, Reasons = @Reasons&#13;&#10;where id = @id">
            <SelectParameters>
                <asp:ControlParameter ControlID="gvNotesRefuse" Name="id" PropertyName="SelectedValue"
                    Type="Int32" />
            </SelectParameters>
            <UpdateParameters>
                <asp:Parameter Name="ItName" />
                <asp:Parameter Name="CityAP" />
                <asp:Parameter Name="DateStart" />
                <asp:Parameter Name="DateStop" />
                <asp:Parameter Name="Duration" />
                <asp:Parameter Name="Reasons" />
                <asp:ControlParameter ControlID="gvNotesRefuse" Name="id" PropertyName="SelectedValue" />
            </UpdateParameters>
            <InsertParameters>
                <asp:Parameter Name="ItName" />
                <asp:Parameter Name="CityAP" />
                <asp:Parameter Name="DateStart" />
                <asp:Parameter Name="DateStop" />
                <asp:Parameter Name="Duration" />
                <asp:Parameter Name="Reasons" />
            </InsertParameters>
        </asp:SqlDataSource>
    </div>
</asp:Content>

